﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace TraceThisItem.Domain.Initializers
{
	public class UserConfiguration : EntityTypeConfiguration<User>
	{
		public UserConfiguration()
		{
			HasKey(u => u.UserName);

			Property(u => u.UserName)
				.IsRequired()
				.IsUnicode(false)
				.HasMaxLength(15);

			Property(u => u.Firstname)
				.IsRequired()
				.HasMaxLength(100)
				.IsUnicode(false);

			Property(u => u.Lastname)
				.IsRequired()
				.HasMaxLength(100)
				.IsUnicode(false);

            HasMany(u => u.Teams)
				.WithMany(t => t.Users);
            
			Ignore(u => u.FullName);
		}
	}
}
